﻿using System;
using System.Collections.Generic;

namespace SpaceShooter.Extensions
{
    public static class EnumerableExtension
    {
        public static void Foreach<T>(this IEnumerable<T> list, Action<T> action)
        {
            foreach (T item in list)
            {
                action(item);
            }
        }

        public static void RemoveDeadItems<T>(this IList<T> list, Func<T, bool> action)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (action(list[i]))
                {
                    list.RemoveAt(i);
                }
            }
        }
    }
}
